<template>
  <!--添加工作经历-->
  <div style="background-color: rgb(245, 245, 245);">
    <headers></headers>
    <div class="title">
      <div class="auto">首页  >  认证考试  >  个人账户信息  >  培训经历</div>
    </div>
    <div class="padding250">
      <div class="auto">
        <div class="content">
          <p class="titleName">培训经历</p>

          <div class="formWrapper">
            <Form :label-width="86" label-position="left" class="formMin" >
              <FormItem label="培训机构">
                <Select v-model="tranData.organization" placeholder="请选择培训机构" size="large" style="width: 245px">
                  <Option :value="item.name" v-for="item in peixunList">{{item.name}}</Option>
                </Select>
              </FormItem>
              <FormItem label="培训名称">
                <Input style="width: 245px;" v-model="tranData.organizationContent" size="large" placeholder="请输入培训名称" />
              </FormItem>
              <div class="dateContent clearfix">
                <FormItem label="培训时间" class="pull-left">
                  <DatePicker class="dateRight" v-model="tranData.cultivatestartDateString" type="date" placeholder="开始日期" style="width: 245px" size="large"></DatePicker>
                </FormItem>
                <FormItem class="pull-left">
                  <DatePicker class="dateRight" v-model="tranData.cultivateendDateString" type="date" placeholder="结束日期" style="width: 245px;" size="large"></DatePicker>
                </FormItem>
              </div>
              <FormItem label="" style="width:700px;">
                <p class="tipwords">注：请填写真实工作经历，我们平台会对你提交的资料做背景调查，如虚假将加入企业黑名单。</p>
              </FormItem>
            </Form>
            <Button type="primary" class="save" v-on:click="addPeixun()">保存并返回</Button>
            <Button type="primary" class="save" v-on:click="goBack" style="margin-left: 20px;width: 100px;background-color: #2d8cf0;border-color: #2d8cf0;">返回</Button>
          </div>

        </div>
      </div>
    </div>
    <footers></footers>
  </div>

</template>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  .padding250 .auto{
    background-color: #fff;
    margin-top: 30px;
    text-align: left;
    .content{
      padding: 40px;
      .titleName{
        font-size: 20px;
        color: #000;
        margin-bottom: 40px;
      }

    }
  }
  .title{
    font-size: 14px;
    color: #fff;
    height: 60px;
    line-height: 60px;
    background-color: #2F261E;
    text-align: left;
  }
  .jobdesc{
    height:136px;width:700px;margin-bottom: 10px;
  }


  .save{
    background-color: #B2936B;
    color: #fff;
    height: 50px;
    width: 200px;
    font-size: 16px;
    margin-left: 80px;
  }

  .formWrapper{

    .tipwords{
      font-size: 14px;
      color: #666;
    }
  }




</style>
<script type="text/ecmascript-6">
  import {getTran, addPeixun} from "../../../http"
  import headers from '../../template/header'
  import footers from '../../template/footer'
  export default {
    name: 'addPeixun',
    props: {},
    data() {
      return {
        showOrder: 'kaoshi',
        peixunList: [],
        tranData: {
          organization: '',
          organizationContent: '',
          cultivatestartDate: '',
          cultivateendDate: '',
          cultivatestartDateString: '',
          cultivateendDateString: '',
        }
      };
    },
    methods: {
      goBack() {
        window.history.back();
      },
      getTran(){
        getTran({dicType: 'train'}).then(res => {
          console.info(res.data)
          this.peixunList = res.data
        })
      },
      addPeixun(){
        if(!this.tranData.organization){
          this.$Notice.warning({
            title: "新增培训经历提醒",
            desc: "请选择培训机构",
            duration: 3,
          });
          return
        }
        if(!this.tranData.organizationContent){
          this.$Notice.warning({
            title: "新增培训经历提醒",
            desc: "请填写培训名称",
            duration: 3,
          });
          return
        }
        if(!this.tranData.cultivatestartDateString){
          this.$Notice.warning({
            title: "新增培训经历提醒",
            desc: "请选择培训开始时间",
            duration: 3,
          });
          return
        }
        if(!this.tranData.cultivateendDateString){
          this.$Notice.warning({
            title: "新增培训经历提醒",
            desc: "请选择培训结束时间",
            duration: 3,
          });
          return
        }
        this.tranData.cultivatestartDate = JSON.stringify(this.tranData.cultivatestartDateString).substring(1,11)
        this.tranData.cultivateendDate = JSON.stringify(this.tranData.cultivateendDateString).substring(1,11)
        console.info(this.tranData)
        addPeixun(this.tranData).then(res => {
          if(res.code == 200){
            this.$Notice.success({
              title: '新增培训经历提醒',
              desc: '添加培训经历成功',
              duration: 3,
            });
            this.$router.push({
              name: 'peixun'
            })
          }
        })
      }
    },
    created() {
      this.getTran()
    },
    components: {
      headers,
      footers
    }
  }
</script>
